<?php
class CompanyModel extends AbstractModel{
  protected $tableName = 'company';
  protected $primaryKey = array('company_id');
  public  $data = array(
      'company_id'=>'',
      'server_id'=>0,
      'name'=>'',
      'company_alias'=>'',
  );


	static public function getByUserID($id){
		$db = DBFacade::getConnection();
		$sql='
			SELECT c.* FROM company c
      INNER JOIN "user" u ON u.company_id = c.company_id
      WHERE u.user_id = ?
		';
    $dbh = $db->prepare($sql);
		$dbh->execute(array($id));
    $line = $dbh->fetch();
		if (!empty($line)) return new CompanyModel($line);
		else return false;
	}

}


